/* ---------------------------------------------------------------- 本地缓存 -- */
const Index = {
	// 本地缓存
    local(key,data){ 
        if(arguments.length === 2){
            wx.setStorage({ key, data })
        }else if(arguments.length === 1){
            return wx.getStorageSync(key) || {}
        }
    },
    getUser(){
        return this.local('user')
    },
    localRemove(key, option){
        if(typeof key === 'string'){
            wx.removeStorage({ key, ...option })
        } else{
            wx.removeStorage(option)
        }
    },
    localClear(){
        wx.clearStorage()
    },
    getToken(){
        const user = this.local('user') ?? {}
        return user?.token
    }
}
export default Index
